package com.ycsyxt.admin.controller;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.ycsyxt.admin.entity.ChatMessage;
import com.ycsyxt.admin.page.AjaxResult;
import com.ycsyxt.admin.service.IChatMessageService;

/**
 * @author ycs(15241496739 @ 163.com)
 * @date 2021/10/7
 **/
@RestController
@RequestMapping("/chat/message")
public class ChatMessageController extends BaseController {
    @Autowired
    private IChatMessageService chatMessageService;

    /**
     * 获取聊天消息详细信息
     */
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        ChatMessage chatMessage = chatMessageService.selectChatMessageById(id);
        return AjaxResult.success(chatMessage);
    }

    /**
     * 新增聊天消息
     */
    @PostMapping
    public AjaxResult add(@RequestBody ChatMessage chatMessage) {
        return toAjax(chatMessageService.insertChatMessage(chatMessage));
    }

    /**
     * 修改聊天消息
     */
    @PutMapping
    public AjaxResult edit(@RequestBody ChatMessage chatMessage) {
        return toAjax(chatMessageService.updateChatMessage(chatMessage));
    }

    /**
     * 删除聊天消息
     */
    @DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(chatMessageService.deleteChatMessageByIds(ids));
    }
}
